package java_0570_draw;

import javax.swing.*;
import java.awt.*;

public class DrawCircle extends JFrame {
    private MyPanel mp = null;

    public static void main(String[] args) {
        new DrawCircle();
    }
    public DrawCircle(){
        mp = new MyPanel();
        this.add(mp);
        this.setSize(1000,800);
        this.setVisible(true);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);


    }
}

class MyPanel extends JPanel {
    @Override
    public void paint(Graphics g) {
        super.paint(g);
        g.drawOval(10, 10, 100, 100);

        //画直线 drawLine(int x1 ,int y1 ,int x2,int y2)
        g.drawLine(10,10,100,100);

        //话矩形边框
        g.drawRect(10,10,100,100);

        //填充矩形：1.设置画笔颜色
        g.setColor(Color.CYAN);
        g.fillRect(110,110,100,100);

        //填充椭圆
        g.setColor(Color.CYAN);
        g.fillOval(210,210,100,100);

        //获取图片资源
        Image image = Toolkit.getDefaultToolkit().getImage(MyPanel.class.getResource("/Elysia.jpg"));
        g.drawImage(image,0,0,540,1170,this);

        //画字符串
        g.setColor(Color.CYAN);
        g.setFont(new Font("楷体",Font.BOLD,50));
        g.drawString("Elysia",800,100);





    }
}